/*
 * Copyright 2022-2029 heshuixing(https://gitee.com/heshuixing)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mercury.ec.framework.air.core.channel.mq.consumer;

import com.mercury.ec.framework.air.core.channel.service.AirChannelService;
import com.mercury.ec.module.basic.mq.message.ChannelUpdateMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 针对 {@link ChannelUpdateMessage} 的消费者
 *
 * @author hesx
 */
@Slf4j
@Component
public class ChannelUpdateConsumer {

    @Resource
    private AirChannelService airChannelService;

    @EventListener
    @Async
    public void onMessage(ChannelUpdateMessage message) {
        log.info("[onMessage][消息内容({})]", message);
        airChannelService.clearAirClientCache(message);
    }
}
